import "./index.scss";
import { prince } from '../../../utils/sendRequst';
import { useEffect, useState } from 'react';

const Student = () => {
    let A=0;
    let B=0;
    let C=0;
    let D=0;
    let E=0;
    let F=0;
    let G=0;
    const [a,setA]=useState([])
    const [b,setB]=useState([])
    const [c,setC]=useState([])
    const [d,setD]=useState([])
    const [e,setE]=useState([])
    const [f,setF]=useState([])
    const [g,setG]=useState([])
    const getall = () => {
        prince().then(res => {
            console.log(res);
    
            for(let i = 0;i<res.data.length;i++){
                //销售总额
                A+=res.data[i].orPrice
              

                // 有效订单数
                if(res.data[i].orState!=0){
                    B+=res.data[i].orNum
                  
                }
                // 有效订单总额
                if(res.data[i].orState!=0){
                    C+=res.data[i].orPrice
                   
                }
                // 无效订单总数 
                if(res.data[i].orState==0){
                    D+=res.data[i].orNum
                 
                }
                // 无效订单总额
                if(res.data[i].orState==0){
                    E+=res.data[i].orPrice
                   
                }
                // 已成交订单总数
                if(res.data[i].orState==4){
                    F+=res.data[i].orNum
                    
                }
                // 已成交订单总额
                if(res.data[i].orState==4){
                    G+=res.data[i].orPrice
                    
                }
            }
            setA(A);
            setB(B)
            setC(C)
            setD(D)
            setE(E)
            setF(F)
            setG(G)
        })

    };
    // 自动调用渲染页面数据请求
    useEffect(() => {
        getall()
    }, [])
    return (
        <div className="zonghe">
            <div className="ddfirst"><h3>订单统计</h3></div>
            <div className="ddsecond">
                <div className="ddsecondleft"><p>销售总额</p></div>
                <div className="ddsecondleft"><p>有效订单总数</p></div>
                <div className="ddsecondleft"><p>有效订单总额</p></div>
                <div className="ddsecondleft"><p>无效订单总数</p></div>
                <div className="ddsecondleft"><p>无效订单总额</p></div>
                <div className="ddsecondleft"><p>已成交订单总数</p></div>
                <div className="ddsecondleft"><p>已成交订单综合</p></div>
            </div>
            <div className="ddthree">
                <div className="ddsecondright"><p>{a}</p></div>
                <div className="ddsecondright"><p>{b}</p></div>
                <div className="ddsecondright"><p>{c}</p></div>
                <div className="ddsecondright"><p>{d}</p></div>
                <div className="ddsecondright"><p>{e}</p></div>
                <div className="ddsecondright"><p>{f}</p></div>
                <div className="ddsecondright"><p>{g}</p></div>
            </div>

            <div className="hyfirst"><h3>会员统计</h3></div>
            <div className="hysecond">
                <div className="hysecondleft"><p>用户总数</p></div>
                <div className="hysecondleft"><p>有订单用户</p></div>
                <div className="hysecondleft"><p>用户订单总数</p></div>
                <div className="hysecondleft"><p>用户购物总额</p></div>
                <div className="hysecondleft"><p>用户购买率</p></div>
                <div className="hysecondleft"><p>用户平均订单数</p></div>
                <div className="hysecondleft"><p>用户平均购物额</p></div>
            </div>
            <div className="hythree">
                <div className="hysecondright"><p></p></div>
                <div className="hysecondright"><p></p></div>
                <div className="hysecondright"><p></p></div>
                <div className="hysecondright"><p></p></div>
                <div className="hysecondright"><p></p></div>
                <div className="hysecondright"><p></p></div>
                <div className="hysecondright"><p></p></div>
            </div>
        </div>
    );
}

export default Student;